Skip to content

fix(test): add lcov 2.x version-gated --ignore-errors for coverage scripts - #467

Merged
deepin-bot[bot] merged 2 commits into
linuxdeepin:masterfrom
add-uos:fix-ut-lcov-ignore-errors
Dec 1, 2026
Merged

deepin-bot[bot] merged 2 commits into
linuxdeepin:masterfrom
add-uos:fix-ut-lcov-ignore-errors

Conversation

@add-uos

@add-uos add-uos commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

问题

Gerrit-unittest-check 流水线 CI 镜像的 lcov 为 2.x,对 gcov 计数器与源码不一致(ERROR: (inconsistent) mismatched end line)直接报错中断。项目中所有 lcov/genhtml 调用均未带 --ignore-errors,任一阶段(capture/extract/remove/genhtml)失败即覆盖率无法产出,流水线记录 0.0%。

deepin-screen-recorder(#553/#555/#561,PR #1101/#1103)与 deepin-terminal(#531/#544/#545,PR #608/#609)已确认并修复同因问题:terminal 修复后覆盖率 80.30%、screen-recorder 83.10%。

修复

  • 每个含 lcov 的脚本在第一个调用前插入版本门控:lcov --version 提取主版本号,>= 2 时 LCOV_IG15="--ignore-errors inconsistent,mismatch"
  • 所有 lcov/genhtml 调用注入 $LCOV_IGN(共 N 处)
  • lcov 1.x 不支持该错误类型,LCOV_IGN 为空,行为不变
  • tests/local-test.sh 中 2 处 en-dash(U+2013)误写修正为 ASCII -

验证

  • bash -n 全部通过
  • 本地 lcov 1.14 实测:LCOV_MAJOR=1 → 不加参数(原行为)
  • 门控写法与 deepin-terminal e4798910、deepin-screen-recorder 82ae9f30 完全一致(CI 已验证)

PMS: TASK-398635

Summary by Sourcery

Make coverage scripts tolerate inconsistent gcov data on lcov 2.x.

Bug Fixes:

  • Preserve coverage collection and HTML report generation with lcov 2.x when gcov data has inconsistent or mismatched source lines, while leaving lcov 1.x behavior unchanged.

Chores:

  • Fix two en-dash characters used in place of ASCII hyphens in tests/local-test.sh.

…ripts

CI 镜像 lcov 为 2.x,对 gcov 计数器与源码不一致(inconsistent/mismatch)
直接报错中断,任一阶段失败都会导致覆盖率无法产出(与
deepin-screen-recorder #553、deepin-terminal #531 同因)。按版本门控
(lcov >= 2 才加 --ignore-errors inconsistent,mismatch)注入全部
lcov/genhtml 调用,lcov 1.x 行为不变。

PMS: TASK-398635
Log: CI 单测覆盖率流水线 lcov 2.x 兼容
Influence: 不影响 lcov 1.x 本地行为
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: add-uos

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sourcery-ai

sourcery-ai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Tests

Add lcov-version-gated ignore-error options to the coverage scripts’ lcov and genhtml calls, while preserving lcov 1.x behavior and updating the SPDX headers.

  • tests/local-test.sh L3, L27-45, L51
  • tests/qmake-lcov-test.sh L3, L19-35
  • tests/test-prj-running.sh L55-65, L101-105, L111

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="tests/test-prj-running.sh" line_range="111" />
<code_context>

 # Generate HTML report
-genhtml -o ./html ./coverage.info
+genhtml $LCOV_IGN -o ./html ./coverage.info

 # Rename main index for downstream tooling
</code_context>
<issue_to_address>
**Coverage summary drops metrics**

When lcov 2.x encounters inconsistent or mismatched data while producing the summary, `gen-ut-summary.py` later runs `lcov --summary` without the version-gated ignore option; when that command rejects mismatched coverage data, its output has no metrics for the parser, so `ut-summary.json` is written without coverage fields.

Pass the same version-gated ignore option to the summary invocation, or otherwise handle a failed summary without silently omitting its metrics.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread tests/test-prj-running.sh

# Generate HTML report
genhtml -o ./html ./coverage.info
genhtml $LCOV_IGN -o ./html ./coverage.info

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Coverage summary drops metrics

When lcov 2.x encounters inconsistent or mismatched data while producing the summary, gen-ut-summary.py later runs lcov --summary without the version-gated ignore option; when that command rejects mismatched coverage data, its output has no metrics for the parser, so ut-summary.json is written without coverage fields.

Pass the same version-gated ignore option to the summary invocation, or otherwise handle a failed summary without silently omitting its metrics.

Prompt for AI agents
In `tests/test-prj-running.sh` at line 111:

**Coverage summary drops metrics**

When lcov 2.x encounters inconsistent or mismatched data while producing the summary, `gen-ut-summary.py` later runs `lcov --summary` without the version-gated ignore option; when that command rejects mismatched coverage data, its output has no metrics for the parser, so `ut-summary.json` is written without coverage fields.

Pass the same version-gated ignore option to the summary invocation, or otherwise handle a failed summary without silently omitting its metrics.

- 单年份版权行更新为创建年-2026 区间(CI SPDX 检查要求)
- 为缺失 SPDX header 的脚本补充版权与 license 声明

PMS: TASK-398635
Log: CI SPDX 检查修复
Influence: 仅注释变更,不影响脚本逻辑
@add-uos

add-uos commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot
deepin-bot Bot merged commit d91f128 into linuxdeepin:master Dec 1, 2026
9 checks passed
@deepin-bot

deepin-bot Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

This pr force merged! (status: blocked, merge_method: rebase)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants